import { ref } from 'vue'
import { bindWXInfo, bindWX } from '../axioser'

export function useInterface() {
  // APPID
  const appid = ref('')
  // appsecret
  const appsecret = ref('')

  //   获取模糊的appid和appsecret
  const getAppConfig = async () => {
    try {
      const {
        data: { data },
      } = await bindWXInfo()
      appid.value = data.appid
      appsecret.value = data.appsecret
    } catch (error) {
      console.error(error)
    }
  }

  //   更改绑定
  const onReBind = async () => {
    try {
      const {
        data: { code },
      } = await bindWX({ appid: appid.value, appsecret: appsecret.value })
      console.log(code)
    } catch (error) {
      console.error(error)
    }
  }
  return {
    appid,
    appsecret,
    getAppConfig,
    onReBind,
  }
}
